-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/prepare json yaml files #5
base: main
Are you sure you want to change the base?
Conversation
Added a small additional description to the ArgumentParser.
Implemented functionality to generate both JSON and YAML files for derivatives in a BIDS dataset, ensuring compatibility with multiple data types. (Pooja's script was missing this) Fixed bugs in JSON file generation for input data, ensuring accurate file parsing and content preparation. (Pooja's script generated empty JSON files for inputs; I resolved this) Completed the addition of -s (source) and -d (destination) command-line arguments to allow users to specify custom input and output paths. (Pooja's TODO—completed by me) Refactored the script extensively to improve code readability and maintainability. How to Run: cd json_yaml_files python3 prepare_file.py -s <path_to_bids_data> -d <desination_path_for_output_files>
self.json_dir = self.destination_path / 'prepared_jsons' | ||
self.yaml_dir = self.destination_path / 'prepared_yamls' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JSONs and YAMLs are pairs of files for upload. Was there a reason to separate them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intresting. Pooja's code did seperate files into seperate folder. Let me go ahead and output the files in single folder.
|
||
def prepare_json_contents(self, file_name, files): | ||
json_contents = {} | ||
_, X, _, _ = self.extract_file_name_components(file_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the A, Y, and Z matches being thrown away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for the change is that we are not using A, Y, or Z in the function. Previously, Pooja's code used X and Y to extract files, but this extraction was redundant since the files had already been extracted using .get
in the for
loop within the run()
function. To address this, I passed the files as an argument to the prepare_json_contents
function, which wasn’t done previously.
This change improves runtime efficiency by avoiding redundant file extraction.
} | ||
|
||
for file_path in files: | ||
sub_path = file_path[file_path.find(sub_path_prefix.get(X, '')):] if X in sub_path_prefix else file_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is hard to read. Please separate it out into an easier-to-understand multiple lines.
|
||
def run(self): | ||
scopes = { | ||
'raw': 'inputs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"raw" is regularly called "rawdata" in BIDS.
files = self.layout.get( | ||
scope=x if x != 'inputs' else 'raw', datatype=y, return_type='file') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand this line into multiple lines for easier reading. Specifically:
x if x != 'inputs' else 'raw'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure I will do that.
Co-authored-by: Eric Earl <[email protected]>
Co-authored-by: Eric Earl <[email protected]>
-s
(source) and-d
(destination) command-line arguments to allow users to specify custom input and output paths. (Pooja's TODO—completed by me)How to Run: